﻿using System;
using System.Configuration;
using System.Xml;
using System.Net.Mail;

namespace Alex.Library.Log.Configuration
{
    /// <summary>
    /// 邮件发送优先级内容元素
    /// </summary>
    public sealed class MailPriorityContentElement : EnumContentElement<MailPriority>
    {
        /// <summary>
        /// 默认构造函数
        /// </summary>
        public MailPriorityContentElement()
        {
            this.Value = MailPriority.Normal;
        }

        /// <summary>
        /// 反序列化配置信息
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="serializeCollectionKey"></param>
        protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey)
        {
            MailPriority priority = MailPriority.Normal;
            object obj = reader.ReadElementContentAsString();
            if (obj != null)
            {
                Enum.TryParse<MailPriority>(obj.ToString(), out priority);
            }
            this.Value = priority;
        }
    }
}
